//--------------------------------------------------------------------------
// 
//  Copyright (c) Chili Software.  All rights reserved. 
// 
//  File: ObjectLoadedEventArgs.cs
//
//  Description: EventArgs for ObjectContext events fired after load.
// 
//--------------------------------------------------------------------------

using System;
using System.Reflection;
using Chili.Opf3.Query;

namespace Chili.Opf3
{
	/// <summary>
	/// EventArgs used in the <see cref="Opf3.ObjectContext">ObjectContext</see> events
	/// that are invoked after the load process of an object.
	/// </summary>
	/// <remarks>
	/// This class is used by the <see cref="Opf3.ObjectContext">ObjectContext</see> in
	/// events that are invoked after the load process of an object to send additional event
	/// data. The data contains the <see cref="Opf3.ObjectInfo">ObjectInfo</see> object that
	/// contains further information about the state of the object and the object itself,
	/// </remarks>
	[Serializable]
	public sealed class ObjectLoadedEventArgs : EventArgs
	{
		private ObjectInfo _objectInfo;
		private object _obj;

		/// <summary>
		/// Creates a new instance of the<see cref="ObjectLoadedEventArgs">ObjectLoadedEventArgs Class</see>.
		/// </summary>
		/// <param name="obj">The object that is affected by the current operation. This object is loaded from the storage.</param>
		/// <param name="objectInfo"><see cref="Opf3.ObjectInfo">ObjectInfo</see> object that contains state information about the persistent object.</param>
		/// <exception cref="System.ArgumentNullException">Query is null, obj is null or objectInfo is null.</exception>
		internal ObjectLoadedEventArgs(object obj, ObjectInfo objectInfo)
		{
			if (obj == null)
				throw new ArgumentNullException("obj");
			if (objectInfo == null)
				throw new ArgumentNullException("objectInfo");

			_objectInfo = objectInfo;
			_obj = obj;
		}

		/// <summary>
		/// Returns the <see cref="Opf3.ObjectInfo">ObjectInfo</see> object that 
		/// contains state information about the persistent object.
		/// </summary>
		/// <value>
		/// The <see cref="ObjectInfo">ObjectInfo</see> object that contains state
		/// information about the persistent object.
		/// </value>
		public ObjectInfo ObjectInfo
		{
			get { return _objectInfo; }
		}

		/// <summary>
		/// Returns the object that is affected by the current operation. This object is
		/// loaded from the storage.
		/// </summary>
		/// <value>The object affected by the current operation.</value>
		public object Object
		{
			get { return _obj; }
		}
	}
}
